package com.yuju.log.service.impl;

import java.math.BigDecimal;
import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.yuju.account.enums.AccountStatusEnum;
import com.yuju.account.enums.BusinessTypeDetailEnum;
import com.yuju.account.enums.BusinessTypeEnum;
import com.yuju.account.model.UnitAccountModel;
import com.yuju.cache.RedisCache;
import com.yuju.common.Result;
import com.yuju.constant.CacheKey;
import com.yuju.enums.LogBizTypeEnum;
import com.yuju.group.service.IAgentCustomService;
import com.yuju.group.service.IGuestInfoService;
import com.yuju.group.service.IProtocolCustomService;
import com.yuju.hotel.enums.CustomersEnum;
import com.yuju.log.model.LogBizRecordModel;
import com.yuju.log.model.LogBizTypeModel;
import com.yuju.log.service.IAccountLogService;
import com.yuju.log.service.ILogBizRecordService;
import com.yuju.model.account.AccountModel;
import com.yuju.order.model.ReserveModel;
import com.yuju.order.model.RoomOrderModel;
import com.yuju.order.service.IReserverService;
import com.yuju.order.service.IRoomOrderService;
import com.yuju.util.Utils;
import com.yuju.vo.account.AccountVO;

/**
 * 
 * 类名：AccountLogServiceImpl  <br />
 *
 * 功能：账务日志服务<br />
 * 包括： 账务日志：订单账务、单位账务
 *
 * @author : xuehj <br />
 * @Date : 2017年12月28日 下午2:22:15  <br />
 * @version : 1.1 <br />
 */
@Service
public class AccountLogServiceImpl implements IAccountLogService {
	
	private RedisCache cache = RedisCache.getInstance();
	
	@Autowired
	private IReserverService reserverService;
	
	@Autowired 
	private IRoomOrderService roomOrderService;
	
	@Autowired
	private ILogBizRecordService logBizRecordService;
	
	@Autowired
	private IGuestInfoService guestInfoService;
	
	@Autowired
	private IProtocolCustomService protocloCustomService;
	
	@Autowired
	private IAgentCustomService agentCustomService;
	
	@Override
	public void before(String path, JSONObject obj) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void log(String path, JSONObject obj, Result ret) {
		try {
			// 收订金
			if (path.equals("/reserveAccount/saveDeposit")) {
				String jsonString  = (String)cache.get(LogBizTypeEnum.ACCOUNT_DJ_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				
				//获得预订单信息
				ReserveModel reserveModel = reserverService.findById(obj.getString("reserveId"));
				
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setOrderNo(reserveModel.getReserveNo());
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.RESERVE_ACCOUNT_LOG_BIZ_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.RESERVE_ACCOUNT_LOG_BIZ_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.BUSINESS_TYPE_DJ.getName())
						.replaceAll("#roomCode#", "")
						.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.getName(obj.getByte("businessTypeDetail")))
						.replaceAll("#money#", obj.getBigDecimal("money").toString()));
	//			logBizRecordModel.setGuestId(reserveModel.getCustomType().toString());
				logBizRecordModel.setGuestName(reserveModel.getReserveName());
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				logBizRecordModel.setRemark(obj.getString("remark"));
				logBizRecordService.save(logBizRecordModel);
			}else if(path.equals("/reserveAccount/saveBackDeposit")){
				String jsonString  = (String)cache.get(LogBizTypeEnum.ACCOUNT_TK_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				//获得预订单信息
				ReserveModel reserveModel = reserverService.findById(obj.getString("reserveId"));
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setOrderNo(reserveModel.getReserveNo());
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.RESERVE_ACCOUNT_LOG_BIZ_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.RESERVE_ACCOUNT_LOG_BIZ_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.BUSINESS_TYPE_TK.getName())
						.replaceAll("#roomCode#", "")
						.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.getName(obj.getByte("businessTypeDetail")))
						.replaceAll("#money#", obj.getBigDecimal("money").toString()));
				logBizRecordModel.setGuestName(reserveModel.getReserveName());
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				logBizRecordModel.setRemark(obj.getString("remark"));
				logBizRecordService.save(logBizRecordModel);
			}else if(path.equals("/reserveAccount/saveReduce")){
				String jsonString  = (String)cache.get(obj.getString("businessType")+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				//获得预订单信息
				ReserveModel reserveModel = reserverService.findById(obj.getString("reserveId"));
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setOrderNo(reserveModel.getReserveNo());
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.RESERVE_ACCOUNT_LOG_BIZ_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.RESERVE_ACCOUNT_LOG_BIZ_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.getName(obj.getByte("businessType")))
						.replaceAll("#roomCode#", "")
						.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.getName(obj.getByte("businessTypeDetail")))
						.replaceAll("#money#", obj.getBigDecimal("money").multiply(new BigDecimal("-1")).toString()));
				logBizRecordModel.setGuestName(reserveModel.getReserveName());
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				logBizRecordModel.setRemark(obj.getString("remark"));
				logBizRecordService.save(logBizRecordModel);
			}else if(path.equals("/settle/saveQT")){
				String jsonString  = (String)cache.get(LogBizTypeEnum.ACCOUNT_QT_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				//获得订单信息
				RoomOrderModel roomOrderModel = roomOrderService.findById(obj.getString("roomOrderId"));
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setOrderNo(roomOrderModel.getRoomOrderNo());
				logBizRecordModel.setRoomCode(roomOrderModel.getRoomCode());
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.BUSINESS_TYPE_QT.getName())
						.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
						.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.BUSINESS_TYPE_DETAIL_QT.getName())
						.replaceAll("#money#", obj.getBigDecimal("money").toString()));
				logBizRecordModel.setGuestId(obj.getString("roomGuestId"));
				logBizRecordModel.setGuestName(guestInfoService.findById(obj.getString("roomGuestId")).getName());
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				logBizRecordModel.setRemark(obj.getString("remark"));
				logBizRecordService.save(logBizRecordModel);
			}else if(path.equals("/settle/saveMD")){
				String jsonString  = (String)cache.get(LogBizTypeEnum.ACCOUNT_MD_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				//获得订单信息
				RoomOrderModel roomOrderModel = roomOrderService.findById(obj.getString("roomOrderId"));
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setOrderNo(roomOrderModel.getRoomOrderNo());
				logBizRecordModel.setRoomCode(roomOrderModel.getRoomCode());
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.BUSINESS_TYPE_MD.getName())
						.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
						.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.BUSINESS_TYPE_DETAIL_QT.getName())
						.replaceAll("#money#", obj.getBigDecimal("money").toString()));
				logBizRecordModel.setGuestId(obj.getString("roomGuestId"));
				logBizRecordModel.setGuestName(guestInfoService.findById(obj.getString("roomGuestId")).getName());
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				logBizRecordModel.setRemark(obj.getString("remark"));
				logBizRecordService.save(logBizRecordModel);
			}else if(path.equals("/settle/saveFF")){
				String jsonString  = (String)cache.get(LogBizTypeEnum.ACCOUNT_JSFF_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				//获得订单信息
				RoomOrderModel roomOrderModel = roomOrderService.findById(obj.getString("roomOrderId"));
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setOrderNo(roomOrderModel.getRoomOrderNo());
				logBizRecordModel.setRoomCode(roomOrderModel.getRoomCode());
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.BUSINESS_TYPE_JSFF.getName())
						.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
						.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.getName(obj.getByte("businessTypeDetail")))
						.replaceAll("#money#", obj.getBigDecimal("money").toString()));
				logBizRecordModel.setGuestId(obj.getString("roomGuestId"));
				logBizRecordModel.setGuestName(guestInfoService.findById(obj.getString("roomGuestId")).getName());
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				logBizRecordModel.setRemark(obj.getString("remark"));
				logBizRecordService.save(logBizRecordModel);
			}else if(path.equals("/settle/saveTK")){
				String jsonString  = (String)cache.get(LogBizTypeEnum.ACCOUNT_TK_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				//获得订单信息
				RoomOrderModel roomOrderModel = roomOrderService.findById(obj.getString("roomOrderId"));
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setOrderNo(roomOrderModel.getRoomOrderNo());
				logBizRecordModel.setRoomCode(roomOrderModel.getRoomCode());
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.BUSINESS_TYPE_TK.getName())
						.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
						.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.getName(obj.getByte("businessTypeDetail")))
						.replaceAll("#money#", obj.getBigDecimal("money").toString()));
				logBizRecordModel.setGuestId(obj.getString("roomGuestId"));
				logBizRecordModel.setGuestName(guestInfoService.findById(obj.getString("roomGuestId")).getName());
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				logBizRecordModel.setRemark(obj.getString("remark"));
				logBizRecordService.save(logBizRecordModel);
			}else if(path.equals("/settle/saveSK")){
				String jsonString  = (String)cache.get(LogBizTypeEnum.ACCOUNT_SK_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				//获得订单信息
				RoomOrderModel roomOrderModel = roomOrderService.findById(obj.getString("roomOrderId"));
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setOrderNo(roomOrderModel.getRoomOrderNo());
				logBizRecordModel.setRoomCode(roomOrderModel.getRoomCode());
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.BUSINESS_TYPE_SK.getName())
						.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
						.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.getName(obj.getByte("businessTypeDetail")))
						.replaceAll("#money#", obj.getBigDecimal("money").toString()));
				logBizRecordModel.setGuestId(obj.getString("roomGuestId"));
				logBizRecordModel.setGuestName(guestInfoService.findById(obj.getString("roomGuestId")).getName());
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				logBizRecordModel.setRemark(obj.getString("remark"));
				logBizRecordService.save(logBizRecordModel);
			}else if(path.equals("/settle/saveYJ")){
				String jsonString  = (String)cache.get(LogBizTypeEnum.ACCOUNT_YJ_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				//获得订单信息
				RoomOrderModel roomOrderModel = roomOrderService.findById(obj.getString("roomOrderId"));
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setOrderNo(roomOrderModel.getRoomOrderNo());
				logBizRecordModel.setRoomCode(roomOrderModel.getRoomCode());
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.BUSINESS_TYPE_YJ.getName())
						.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
						.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.getName(obj.getByte("businessTypeDetail")))
						.replaceAll("#money#", obj.getBigDecimal("money").toString()));
				logBizRecordModel.setGuestId(obj.getString("roomGuestId"));
				logBizRecordModel.setGuestName(guestInfoService.findById(obj.getString("roomGuestId")).getName());
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				logBizRecordModel.setRemark(obj.getString("remark"));
				logBizRecordService.save(logBizRecordModel);
			}else if(path.equals("/settle/saveCT")){
				String jsonString  = (String)cache.get(obj.getString("businessType")+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				//获得订单信息
				RoomOrderModel roomOrderModel = roomOrderService.findById(obj.getString("roomOrderId"));
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setOrderNo(roomOrderModel.getRoomOrderNo());
				logBizRecordModel.setRoomCode(roomOrderModel.getRoomCode());
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.getName(obj.getByte("businessType")))
						.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
						.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.getName(obj.getByte("businessTypeDetail")))
						.replaceAll("#money#", obj.getBigDecimal("money").multiply(new BigDecimal("-1")).toString()));
				logBizRecordModel.setGuestId(obj.getString("roomGuestId"));
				logBizRecordModel.setGuestName(guestInfoService.findById(obj.getString("roomGuestId")).getName());
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				logBizRecordModel.setRemark(obj.getString("remark"));
				logBizRecordService.save(logBizRecordModel);
			}else if(path.equals("/settle/saveXSD")){
				String jsonString  = (String)cache.get(LogBizTypeEnum.ACCOUNT_XSD_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				//获得订单信息
				RoomOrderModel roomOrderModel = roomOrderService.findById(obj.getString("roomOrderId"));
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setOrderNo(roomOrderModel.getRoomOrderNo());
				logBizRecordModel.setRoomCode(roomOrderModel.getRoomCode());
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setGuestId(obj.getString("roomGuestId"));
				logBizRecordModel.setGuestName(guestInfoService.findById(obj.getString("roomGuestId")).getName());
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				//获得商品账务信息
				JSONArray jsonArray = obj.getJSONArray("list");
				String jsonStr = jsonArray.toJSONString();
				ArrayList<AccountModel> accounts = JSON.parseObject(jsonStr, new TypeReference<ArrayList<AccountModel>>(){});
				for (AccountModel accountModel : accounts) {
					logBizRecordModel.setRemark(accountModel.getRemark());
					logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.BUSINESS_TYPE_XSD.getName())
							.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
							.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.getName(accountModel.getBusinessTypeDetail()))
							.replaceAll("#money#", accountModel.getMoney().toString()));
					logBizRecordService.save(logBizRecordModel);
				}
				
				if(Utils.isNotNull(obj.getBigDecimal("money"))){
					String jsonStringFX  = (String)cache.get(LogBizTypeEnum.ACCOUNT_SK_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
					JSONObject jsonObjectFX = JSONObject.parseObject(jsonStringFX);
					LogBizTypeModel modelFX = JSONObject.toJavaObject(jsonObjectFX, LogBizTypeModel.class);
					LogBizRecordModel logBizRecordModelZF = new LogBizRecordModel();
					logBizRecordModelZF.setGroupId(obj.getString("groupId"));
					logBizRecordModelZF.setHotelId(obj.getString("hotelId"));
					logBizRecordModelZF.setOrderNo(roomOrderModel.getRoomOrderNo());
					logBizRecordModel.setRoomCode(roomOrderModel.getRoomCode());
					logBizRecordModelZF.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
					logBizRecordModelZF.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
					logBizRecordModelZF.setBizTypeId(new Byte(model.getId()));
					logBizRecordModelZF.setBizTypeCode(model.getCode());
					logBizRecordModelZF.setBizTypeName(model.getName());
					logBizRecordModelZF.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.BUSINESS_TYPE_SK.getName())
							.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
							.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.BUSINESS_TYPE_DETAIL_XJ.getName())
							.replaceAll("#money#", obj.getBigDecimal("money").toString()));
					logBizRecordModel.setGuestId(obj.getString("roomGuestId"));
					logBizRecordModel.setGuestName(guestInfoService.findById(obj.getString("roomGuestId")).getName());
					logBizRecordModelZF.setCreateUserId(obj.getString("empId"));
					logBizRecordModelZF.setCreateUserName(obj.getString("empName"));
					logBizRecordModelZF.setRemark(obj.getString("remark"));
					logBizRecordService.save(logBizRecordModelZF);
				}
			}else if(path.equals("/orderAccount/saveZJ")){
				String jsonString  = (String)cache.get(LogBizTypeEnum.CHECKOUT_SETTLE_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				RoomOrderModel roomOrderModel = roomOrderService.findById(obj.getString("roomOrderId"));
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setOrderNo(roomOrderModel.getRoomOrderNo());
				logBizRecordModel.setRoomCode(roomOrderModel.getRoomCode());
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.CHECKOUT_LOG_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.CHECKOUT_LOG_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", LogBizTypeEnum.CHECKOUT_SETTLE_LOG_BIZ_TYPE.getName())
						.replaceAll("#remark#", obj.getString("gowhy"))
						.replaceAll("#roomCode#", roomOrderModel.getRoomCode()));
				logBizRecordModel.setGuestId(obj.getString("roomGuestId"));
				logBizRecordModel.setGuestName(guestInfoService.findById(obj.getString("roomGuestId")).getName());
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				logBizRecordModel.setRemark(obj.getString("remark"));
				logBizRecordService.save(logBizRecordModel);
				
			}else if(path.equals("/orderAccount/endSettle")){
				JSONArray jsonArray = obj.getJSONArray("accounts");
				String jsonString = jsonArray.toJSONString();
				ArrayList<AccountVO> accounts = JSON.parseObject(jsonString, new TypeReference<ArrayList<AccountVO>>(){});
				RoomOrderModel roomOrderModel = roomOrderService.findById(obj.getString("roomOrderId"));
				boolean flag = false;
				for (AccountVO accountVO : accounts) {
					String jsonStringA  = (String)cache.get(accountVO.getBusinessType().toString()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
					JSONObject jsonObject = JSONObject.parseObject(jsonStringA);
					LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
					
					LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
					logBizRecordModel.setGroupId(obj.getString("groupId"));
					logBizRecordModel.setHotelId(obj.getString("hotelId"));
					logBizRecordModel.setOrderNo(roomOrderModel.getRoomOrderNo());
					logBizRecordModel.setRoomCode(roomOrderModel.getRoomCode());
					logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
					logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
					logBizRecordModel.setBizTypeId(new Byte(model.getId()));
					logBizRecordModel.setBizTypeCode(model.getCode());
					logBizRecordModel.setBizTypeName(model.getName());
					logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.getName(accountVO.getBusinessType()))
							.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
							.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.getName(accountVO.getBusinessTypeDetail()))
							.replaceAll("#money#", accountVO.getMoney().toString()));
					logBizRecordModel.setGuestId(accountVO.getRoomGuestId());
					logBizRecordModel.setGuestName(guestInfoService.findById(accountVO.getRoomGuestId()).getName());
					logBizRecordModel.setCreateUserId(obj.getString("empId"));
					logBizRecordModel.setCreateUserName(obj.getString("empName"));
					logBizRecordModel.setRemark(accountVO.getRemark());
					logBizRecordService.save(logBizRecordModel);
					
					if(Utils.isNull(accountVO.getId())){
						flag = true;
						String jsonStringB  = (String)cache.get(LogBizTypeEnum.CHECKOUT_SETTLE_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
						JSONObject jsonObjectB = JSONObject.parseObject(jsonStringB);
						LogBizTypeModel modelB = JSONObject.toJavaObject(jsonObjectB, LogBizTypeModel.class);
						LogBizRecordModel logBizRecordModelA = new LogBizRecordModel();
						logBizRecordModelA.setGroupId(obj.getString("groupId"));
						logBizRecordModelA.setHotelId(obj.getString("hotelId"));
						logBizRecordModelA.setOrderNo(roomOrderModel.getRoomOrderNo());
						logBizRecordModelA.setRoomCode(roomOrderModel.getRoomCode());
						logBizRecordModelA.setLogBizTypeId(LogBizTypeEnum.CHECKOUT_LOG_TYPE.getCode());
						logBizRecordModelA.setLogBizTypeName(LogBizTypeEnum.CHECKOUT_LOG_TYPE.getName());
						logBizRecordModelA.setBizTypeId(new Byte(modelB.getId()));
						logBizRecordModelA.setBizTypeCode(modelB.getCode());
						logBizRecordModelA.setBizTypeName(modelB.getName());
						logBizRecordModelA.setBizDetail(modelB.getTemplate().replaceAll("#businessTypeName#", LogBizTypeEnum.CHECKOUT_SETTLE_LOG_BIZ_TYPE.getName())
								.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
								.replaceAll("#settleTime#", roomOrderModel.getGmtModified().toString())
								.replaceAll("#money#", accountVO.getMoney().toString()));
						logBizRecordModelA.setGuestId(accountVO.getRoomGuestId());
						logBizRecordModelA.setGuestName(guestInfoService.findById(accountVO.getRoomGuestId()).getName());
						logBizRecordModelA.setCreateUserId(obj.getString("empId"));
						logBizRecordModelA.setCreateUserName(obj.getString("empName"));
						logBizRecordService.save(logBizRecordModelA);
					}
				}
				if(!flag){
					String jsonStringB  = (String)cache.get(LogBizTypeEnum.CHECKOUT_SETTLE_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
					JSONObject jsonObjectB = JSONObject.parseObject(jsonStringB);
					LogBizTypeModel modelB = JSONObject.toJavaObject(jsonObjectB, LogBizTypeModel.class);
					LogBizRecordModel logBizRecordModelA = new LogBizRecordModel();
					logBizRecordModelA.setGroupId(obj.getString("groupId"));
					logBizRecordModelA.setHotelId(obj.getString("hotelId"));
					logBizRecordModelA.setOrderNo(roomOrderModel.getRoomOrderNo());
					logBizRecordModelA.setRoomCode(roomOrderModel.getRoomCode());
					logBizRecordModelA.setLogBizTypeId(LogBizTypeEnum.CHECKOUT_LOG_TYPE.getCode());
					logBizRecordModelA.setLogBizTypeName(LogBizTypeEnum.CHECKOUT_LOG_TYPE.getName());
					logBizRecordModelA.setBizTypeId(new Byte(modelB.getId()));
					logBizRecordModelA.setBizTypeCode(modelB.getCode());
					logBizRecordModelA.setBizTypeName(modelB.getName());
					logBizRecordModelA.setBizDetail(modelB.getTemplate().replaceAll("#businessTypeName#", LogBizTypeEnum.CHECKOUT_SETTLE_LOG_BIZ_TYPE.getName())
							.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
							.replaceAll("#settleTime#", roomOrderModel.getGmtModified().toString())
							.replaceAll("#money#", "0"));
					logBizRecordModelA.setGuestId(roomOrderModel.getMainGuestId());
					logBizRecordModelA.setGuestName(guestInfoService.findById(roomOrderModel.getMainGuestId()).getName());
					logBizRecordModelA.setCreateUserId(obj.getString("empId"));
					logBizRecordModelA.setCreateUserName(obj.getString("empName"));
					logBizRecordService.save(logBizRecordModelA);
				}
			}else if(path.equals("/settle/saveGZ")){
				String jsonString  = (String)cache.get(obj.getString("businessType")+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				//获得订单信息
				RoomOrderModel roomOrderModel = roomOrderService.findById(obj.getString("roomOrderId"));
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setOrderNo(roomOrderModel.getRoomOrderNo());
				logBizRecordModel.setRoomCode(roomOrderModel.getRoomCode());
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.getName(obj.getByte("businessType")))
						.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
						.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.BUSINESS_TYPE_DETAIL_QT.getName())
						.replaceAll("#money#", obj.getBigDecimal("money").toString()));
				logBizRecordModel.setGuestId(obj.getString("roomGuestId"));
				logBizRecordModel.setGuestName(guestInfoService.findById(obj.getString("roomGuestId")).getName());
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				logBizRecordModel.setRemark(obj.getString("remark"));
				logBizRecordService.save(logBizRecordModel);
				
				if(obj.getByte("businessType") == BusinessTypeEnum.BUSINESS_TYPE_DWZF.getValue()){
					String jsonStr  = (String)cache.get(LogBizTypeEnum.ACCOUNT_DWDF_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
					JSONObject jsonObj = JSONObject.parseObject(jsonStr);
					LogBizTypeModel logBizTypeModel = JSONObject.toJavaObject(jsonObj, LogBizTypeModel.class);
					LogBizRecordModel logBizRecordModelZF = new LogBizRecordModel();
					logBizRecordModelZF.setGroupId(obj.getString("groupId"));
					logBizRecordModelZF.setHotelId(obj.getString("hotelId"));
					logBizRecordModelZF.setOrderNo(roomOrderModel.getRoomOrderNo());
					logBizRecordModel.setRoomCode(roomOrderModel.getRoomCode());
					logBizRecordModelZF.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
					logBizRecordModelZF.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
					logBizRecordModelZF.setBizTypeId(new Byte(logBizTypeModel.getId()));
					logBizRecordModelZF.setBizTypeCode(logBizTypeModel.getCode());
					logBizRecordModelZF.setBizTypeName(logBizTypeModel.getName());
					logBizRecordModelZF.setBizDetail(logBizTypeModel.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.BUSINESS_TYPE_DWDF.getName())
							.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
							.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.BUSINESS_TYPE_DETAIL_QT.getName())
							.replaceAll("#money#", obj.getBigDecimal("money").toString()));
					logBizRecordModelZF.setGuestId(obj.getString("customAccNo"));
					logBizRecordModelZF.setGuestName(obj.getString("accountName"));
					logBizRecordModelZF.setCreateUserId(obj.getString("empId"));
					logBizRecordModelZF.setCreateUserName(obj.getString("empName"));
					logBizRecordService.save(logBizRecordModelZF);
				}else if(obj.getByte("businessType") == BusinessTypeEnum.BUSINESS_TYPE_ZJZF.getValue()){
					String jsonStr  = (String)cache.get(LogBizTypeEnum.ACCOUNT_ZJDF_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
					JSONObject jsonObj = JSONObject.parseObject(jsonStr);
					LogBizTypeModel logBizTypeModel = JSONObject.toJavaObject(jsonObj, LogBizTypeModel.class);
					LogBizRecordModel logBizRecordModelZF = new LogBizRecordModel();
					logBizRecordModelZF.setGroupId(obj.getString("groupId"));
					logBizRecordModelZF.setHotelId(obj.getString("hotelId"));
					logBizRecordModelZF.setOrderNo(roomOrderModel.getRoomOrderNo());
					logBizRecordModel.setRoomCode(roomOrderModel.getRoomCode());
					logBizRecordModelZF.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
					logBizRecordModelZF.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
					logBizRecordModelZF.setBizTypeId(new Byte(logBizTypeModel.getId()));
					logBizRecordModelZF.setBizTypeCode(logBizTypeModel.getCode());
					logBizRecordModelZF.setBizTypeName(logBizTypeModel.getName());
					logBizRecordModelZF.setBizDetail(logBizTypeModel.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.BUSINESS_TYPE_DWDF.getName())
							.replaceAll("#roomCode#", roomOrderModel.getRoomCode())
							.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.BUSINESS_TYPE_DETAIL_QT.getName())
							.replaceAll("#money#", obj.getBigDecimal("money").toString()));
					logBizRecordModelZF.setGuestId(obj.getString("customAccNo"));
					logBizRecordModelZF.setGuestName(obj.getString("accountName"));
					logBizRecordModelZF.setCreateUserId(obj.getString("empId"));
					logBizRecordModelZF.setCreateUserName(obj.getString("empName"));
					logBizRecordService.save(logBizRecordModelZF);
				}else if(obj.getByte("businessType") == BusinessTypeEnum.BUSINESS_TYPE_TRZF.getValue()){
					String jsonStr  = (String)cache.get(LogBizTypeEnum.ACCOUNT_GRDF_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
					JSONObject jsonObj = JSONObject.parseObject(jsonStr);
					LogBizTypeModel logBizTypeModel = JSONObject.toJavaObject(jsonObj, LogBizTypeModel.class);
					RoomOrderModel roomOrderModelZF = roomOrderService.findById(obj.getString("roomOrderIdZF"));
					
					LogBizRecordModel logBizRecordModelZF = new LogBizRecordModel();
					logBizRecordModelZF.setGroupId(obj.getString("groupId"));
					logBizRecordModelZF.setHotelId(obj.getString("hotelId"));
					logBizRecordModelZF.setOrderNo(obj.getString("roomOrderIdZF"));
					logBizRecordModelZF.setRoomCode(roomOrderModelZF.getRoomCode());
					logBizRecordModelZF.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
					logBizRecordModelZF.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
					logBizRecordModelZF.setBizTypeId(new Byte(logBizTypeModel.getId()));
					logBizRecordModelZF.setBizTypeCode(logBizTypeModel.getCode());
					logBizRecordModelZF.setBizTypeName(logBizTypeModel.getName());
					logBizRecordModelZF.setBizDetail(logBizTypeModel.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.BUSINESS_TYPE_GRDF.getName())
							.replaceAll("#roomCode#", roomOrderModelZF.getRoomCode())
							.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.BUSINESS_TYPE_DETAIL_QT.getName())
							.replaceAll("#money#", obj.getBigDecimal("money").toString()));
					logBizRecordModelZF.setGuestId(roomOrderModelZF.getMainGuestId());
					logBizRecordModelZF.setGuestName(roomOrderModelZF.getName());
					logBizRecordModelZF.setCreateUserId(obj.getString("empId"));
					logBizRecordModelZF.setCreateUserName(obj.getString("empName"));
					logBizRecordService.save(logBizRecordModelZF);
				}
			}else if(path.equals("/unitAccount/saveYSK")){
				String jsonString  = (String)cache.get(LogBizTypeEnum.ACCOUNT_GRDF_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setBizDetail(model.getTemplate().replaceAll("#businessTypeName#", BusinessTypeEnum.BUSINESS_TYPE_YSK.getName())
						.replaceAll("#roomCode#", "")
						.replaceAll("#businessTypeDetailName#", BusinessTypeDetailEnum.getName(obj.getByte("businessTypeDetail")))
						.replaceAll("#money#", obj.getBigDecimal("money").toString()));
				logBizRecordModel.setGuestId(obj.getString("customId"));
				String name = null;
				if(obj.getByte("customType") == CustomersEnum.CUSTOMERS_XYDW.getValue()){
					name  = protocloCustomService.findById(obj.getString("customId")).getName();
				}else if(obj.getByte("customType") == CustomersEnum.CUSTOMERS_OTA.getValue()){
					name  = agentCustomService.findById(obj.getString("customId")).getName();
				}
				logBizRecordModel.setGuestName(name);
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				logBizRecordModel.setRemark(obj.getString("remark"));
				logBizRecordService.save(logBizRecordModel);
			}else if(path.equals("/unitAccount/saveUnitAccount") || path.equals("/unitAccount/settle")){
				String jsonString = null;
				if(obj.getByte("customType") == CustomersEnum.CUSTOMERS_XYDW.getValue()){
					jsonString  = (String)cache.get(LogBizTypeEnum.ACCOUNT_DWJS_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				}else if(obj.getByte("customType") == CustomersEnum.CUSTOMERS_OTA.getValue()){
					jsonString  = (String)cache.get(LogBizTypeEnum.ACCOUNT_ZJJS_LOG_BIZ_TYPE.getCode()+CacheKey.KEY_CACHE_LOG_BIZ_TYPE);
				}
				JSONObject jsonObject = JSONObject.parseObject(jsonString);
				LogBizTypeModel model = JSONObject.toJavaObject(jsonObject, LogBizTypeModel.class);
				
				JSONArray jsonArray = obj.getJSONArray("unitAccountModelList");
				String jsonStr = jsonArray.toJSONString();
				ArrayList<UnitAccountModel> unitAccountModelList = JSON.parseObject(jsonStr,new TypeReference<ArrayList<UnitAccountModel>>(){});
				LogBizRecordModel logBizRecordModel = new LogBizRecordModel();
				logBizRecordModel.setGroupId(obj.getString("groupId"));
				logBizRecordModel.setHotelId(obj.getString("hotelId"));
				logBizRecordModel.setLogBizTypeId(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getCode());
				logBizRecordModel.setLogBizTypeName(LogBizTypeEnum.ACCOUNT_LOG_TYPE.getName());
				logBizRecordModel.setBizTypeId(new Byte(model.getId()));
				logBizRecordModel.setBizTypeCode(model.getCode());
				logBizRecordModel.setBizTypeName(model.getName());
				logBizRecordModel.setGuestId(obj.getString("customId"));
				String name = null;
				if(obj.getByte("customType") == CustomersEnum.CUSTOMERS_XYDW.getValue()){
					name  = protocloCustomService.findById(obj.getString("customId")).getName();
				}else if(obj.getByte("customType") == CustomersEnum.CUSTOMERS_OTA.getValue()){
					name  = agentCustomService.findById(obj.getString("customId")).getName();
				}
				logBizRecordModel.setGuestName(name);
				logBizRecordModel.setCreateUserId(obj.getString("empId"));
				logBizRecordModel.setCreateUserName(obj.getString("empName"));
				for (UnitAccountModel unitAccountModel : unitAccountModelList) {
					logBizRecordModel.setRemark(unitAccountModel.getRemark());
					logBizRecordModel.setBizDetail(model.getTemplate()
							.replaceAll("#businessTypeName#",
									BusinessTypeEnum.getName(unitAccountModel.getBusinessType()))
							.replaceAll("#roomCode#", "")
							.replaceAll("#businessTypeDetailName#",
									BusinessTypeDetailEnum.getName(unitAccountModel.getBusinessTypeDetail()))
							.replaceAll("#money#", unitAccountModel.getMoney().toString()));
					logBizRecordService.save(logBizRecordModel);
				}
				
			}
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
	}

}
